

<style>
.layui-table-cell{padding:1px 2px;text-align:center;font-size:13px;line-height:19px;}
.layui-form-pane .layui-form-label{width:auto;}
.layui-form-item{margin-bottom: 0px;}

</style>
<div class="fixed-bar">
<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
<div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-inline">
          <input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
        </div>
    </div>
    {if env('env_site') == 'riwei' }
    <div class="layui-inline">
        <label class="layui-form-label">客户单号</label>
        <div class="layui-input-inline">
            <input type="text" name="ext_id" lay-verify="" placeholder="输入客户单号" class="layui-input">
        </div>
    </div>
    {/if}
    <div class="layui-inline removeStat">
        <label class="layui-form-label">SKU</label>
        <div class="layui-input-inline">
          <input type="text" name="sku" lay-verify="" placeholder="输入SKU" class="layui-input">
        </div>
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">所属工厂</label>
            <div class="layui-input-inline">
                <select name="factory_id" lay-filter="factory" xm-select="method-value-example1">
                    <option value=""></option>
                    {volist name="factoryKV" id="key"}
                    <option class="opt" value="{$key}">{$factoryKV[$key]}</option>
                    {/volist}
                </select>
            </div>
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">裁剪类型</label>
        <div class="layui-input-inline">
          {:Form::select('caichuang_type', '', ['' => '请选择', 1=>'手工裁剪', 2=>'电脑裁剪'], '', '')}
        </div>
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">裁剪人员</label>
        <div class="layui-input-inline">
            <select name="caichuang_user_name" lay-filter="user_name" xm-select="method-value-example2">
                <option value=""></option>
                {volist name="caichuangUserKV" id="key"}
                <option class="opt" value="{$key}">{$caichuangUserKV[$key]}</option>
                {/volist}
            </select>
        </div>
        
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">下单日期</label>
        <div class="layui-input-inline time_input">
          <input type="text" name="create_date_range" readonly="" id="create_date_range" lay-verify="" placeholder="选择下单日期" class="layui-input">
        </div>
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">裁床完成日期</label>
        <div class="layui-input-inline time_input">
          <input type="text" name="caichuang_over_date_range" readonly="" id="caichuang_over_date_range" lay-verify="" placeholder="选择裁床完成日期" class="layui-input">

        </div>
    </div>
    <div class="layui-inline removeStat">
        <label class="layui-form-label">是否合裁</label>
          <div class="layui-input-inline shotselect">
              {:Form::select('is_omc', 2, [2 => '请选择', 0=>'不合裁', 1=>'合裁'], '', '')}
          </div>
    </div>
    <div class="layui-inline">
		<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
        <button type="button" class="layui-btn layui-btn-primary hisi-export">导出</button>
		
	</div>
</div>
</form>
</div>
<!-- 进度统计 -->
    <div class="layui-collapse removeStat" lay-accordion>
      <div class="layui-colla-item">
        <h2 class="layui-colla-title">数据统计</h2>
        <div class="layui-colla-content layui-show">
          <table class="layui-table">
            <thead>
              <tr>
                <th>不含尾货</th>
                <th>已裁单数</th>
                <th>已裁件数</th>
                <th>辅料发放单数</th>
                <th>辅料未发放单数</th>
                <th>辅料采购未完成</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>单数</td>
                <td><a href="{:url()}?a=stat&sc=caichuangOverCount" class="stat-coc-item hisi-iframe" title="已裁单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td class="stat-allq-item">0</td>
                <td><a href="{:url()}?a=stat&sc=acOverCount" class="stat-aoc-item hisi-iframe" title="辅料发放单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=acNotCount" class="stat-anc-item hisi-iframe" title="辅料未发放单数" hisi-data="{width: '80%', height: '80%'}">0</a></td>
                <td><a href="{:url()}?a=stat&sc=acNoCount" class="stat-acNoCount-item hisi-iframe" title="辅料采购未完成" hisi-data="{width: '80%', height: '80%'}">0</a></td>
              </tr>
              <tr>
                <td>完成率</td>
                <td class=""></td>	
                <td class=""></td>	
                <td class="stat-aocp-item">0%</td>
                <td class="stat-ancp-item">0%</td>
                <td class="stat-acNoCountp-item">0%</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>

<table id="dataTable"></table>
{include file="system@block/layui" /}
<script type="text/html" id="hecaiTpl">
	{{# if(d.omc_status==1){ }}
		合裁
	{{# }else{ }}
		不合裁
	{{# } }}
</script>
<script type="text/html" id="neadendtTpl">
    <div>{{d.omInfo.caichuang_t_neadend}}</div>
</script>
<script type="text/html" id="stripTpl">
    <div>{{d.omInfo.caichuang_t_strip}}</div>
</script>

<script type="text/html" id="shrinkLengthTpl">
    <div>{{d.omInfo.shrink_length}}</div>
</script>
<script type="text/html" id="caiGouCountTpl">
    <div>{{d.omInfo.billing_caigou_count}}</div>
</script>
<script type="text/html" id="timeTpl">
    <div>{{layui.util.toDateString(d.caichuang_over_time * 1000)}}</div>
</script>
<script type="text/html" id="picTpl">
    <span class="lay-pic-container" src="{{d.pic.pic}}">
        <img src="{{d.pic.pic}}" style="max-width:50px;" class="lay-pic">
    </span>
</script>
<script type="text/html" id="skuTpl">
    <span class="copy-item">{{ d.sku }}</span>
</script>
<script type="text/html" id="caiChuangUserTpl">
    {{# if (d.caichuang_user_name!=null) { }}   
  		<div>{{d.caichuang_user_name.name}}</div>
    {{# } else { }}  
      
    {{# } }}                            
</script>
    
 <script type="text/html" id="caiChuangTypeTpl">
    {{# if (d.caichuang_type=='1') { }}   
  		手工裁剪
    {{# } else { }}  
      电脑裁剪
    {{# } }}  
</script>   
<script type="text/html" id="shiJiCount">
    {{# if (d.omInfo.caichuang_t_wheat_low_length=='' || d.omInfo.caichuang_t_wheat_low_length=='0.00' && d.omInfo.caichuang_t_wheat_height_length=='0.00') { }}   
  		<div>0.00</div>
    {{# } else { }}  
      <div>{{(d.omInfo.caichuang_t_wheat_low_length + d.omInfo.caichuang_t_wheat_height_length) (d.omInfo.caichuang_t_wheat_low_length + d.omInfo.caichuang_t_wheat_height_number) }}</div>
    {{# } }}                
    
</script>
<script type="text/html" id="shiCaiCountTpl">
    <div>{{d.omInfo.shicai_count}}</div>
</script>

<script type="text/html" title="" id="cOrderNumTpl">
            <a href="{:url('task')}?client_ordernum={{d.client_ordernum}}&alert=1" class="hisi-iframe" title="订单详情" hisi-data="{width: '80%', height: '80%'}">{{d.client_ordernum}}</a>
    </script>
<script type="text/javascript">

    layui.use(['opTable','table', 'jquery', 'tool', 'laydate', 'layer', 'form', 'formSelects','laytpl'], function() {
        var $ = layui.jquery;
         var formSelects = layui.formSelects,form = layui.form;
        var table = layui.table;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var laytpl = layui.laytpl;
        //数据统计弹窗操作start
        var where=where1="";
        var hreStr=window.location.search;
        if(hreStr.indexOf("stat") != -1){
            $(".removeStat").remove();
            where1=window.location.search+"&create_date_range="+$.cookie('r_create_date_range')+"&factory_id="+$.cookie('r_factory_id')+"&sku="+$.cookie('r_sku')+"&caichuang_type="+$.cookie('r_caichuang_type')+"&stat_type="+$.cookie('r_stat_type')+"&caichuang_user_name="+$.cookie('r_caichuang_user_name')+"&caichuang_over_date_range="+$.cookie('r_caichuang_over_date_range');
            where=where1+"&client_ordernum="+$.cookie('r_client_ordernum');
            $("#hisi-table-search").attr("action",where1);
        }else{
            where="?a=stat";
        }
        table.render({
            elem : '#dataTable'
            ,url : '{:url()}'+where
            ,page: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,cols : [[ 
                {field:'caichuang_over_time',title : '裁剪时间', templet: '#timeTpl',width:150}
                ,{field:'client_ordernum',title : '订单号', templet:'#cOrderNumTpl',width:100}
                ,{field:'pic',title : '图片', templet:'#picTpl',width:130}
                ,{field:'sku',title : 'sku', templet:'#skuTpl',width:160}
                ,{field:'caichuang_chuanghao',title : '床号',width:80}
                ,{field:'quantity',title : '订单总数', }
                ,{field:'shicai_count',title : '实裁总数'}
                ,{field:'tatal_meter',title : '拉布总米数',}
                ,{field:'caichuang_type',title : '裁剪类型',templet:'#caiChuangTypeTpl'}
                ,{field:'shrink_length',title : '缩水后米数',templet:'#shrinkLengthTpl'}
                ,{field:'billing_caigou_count',title : '开单采购米数',templet:'#caiGouCountTpl'}
                ,{field:'caichuang_shiji_dosage',title : '实际单件用量',templet:function(d){return d.omInfo.caichuang_shiji_dosage}}//单件用量 计算方式：(低层米数+高层米数)/(低层件数+高层件数)
				,{field:'caichuang_user_name',title : '是否合裁',templet:'#hecaiTpl',width:100}
                ,{field:'caichuang_user_name',title : '裁剪员',width:100}
                ,{field:'factory_name',title : '工厂'}
                ,{field:'caichuang_position_txt',title : '裁剪方式',width:80}
                ,{field:'caichuang_t_neadend',title : '布头', templet:'#neadendtTpl',width:80}
                ,{field:'caichuang_t_strip',title : '捆条', templet:'#stripTpl',width:80}
				,{field:'process_price',title : '裁剪单价',width:80}
            ]]
             ,openType : 1
			,done: function(res, curr, count){
				if (res.stat !== undefined) {
                    console.log(res.stat)
					var p = res.stat;
					var w = res.stat.detailWhere;
					$.cookie("r_client_ordernum",w.client_ordernum,{ path:"/" });
					$.cookie("r_create_date_range",w.create_date_range,{ path:"/" });
					$.cookie("r_factory_id",w.factory_id,{ path:"/" });
					$.cookie("r_caichuang_over_date_range",w.caichuang_over_date_range,{ path:"/" });
					$.cookie("r_stat_type",w.stat_type,{ path:"/" });
					$.cookie("r_caichuang_user_name",w.caichuang_user_name,{ path:"/" });
					$.cookie("r_sku",w.sku,{ path:"/" });
					$.cookie("r_caichuang_type",w.caichuang_type,{ path:"/" });
                    
					$('.stat-coc-item').html(p.caichuangOverCount);
                    $('.stat-allq-item').html(p.caichuangAllQuantity);
					$('.stat-aoc-item').html(p.acOverCount);
					$('.stat-anc-item').html(p.acNotCount);
					$('.stat-acNoCount-item').html(p.acNoCount);

					$('.stat-aocp-item').html(p.acOverCountPer);
					$('.stat-ancp-item').html(p.acNotCountPer);
					$('.stat-acNoCountp-item').html(p.acNoCountPer);
				}
			}
        });
        
        laydate.render({
            elem: '#create_date_range'
            ,range: '~'
            ,theme: 'molv'
            ,mark: {'{:$today}':''}
            ,change: function(value, date, endDate){
              $('#create_date_range').val(value);
            	$('#layui-laydate1').remove();//关闭面板
            }
        });
        laydate.render({
            elem: '#caichuang_over_date_range'
            ,range: '~'
            ,theme: 'molv'
            ,mark: {'{:$today}':''}
            ,change: function(value, date, endDate){
              $('#caichuang_over_date_range').val(value);
            	$('#layui-laydate2').remove();//关闭面板
            }
        });
    });
</script>
